<template>
	<view>
		<view class="lb-main-32">
			<!-- 基本信息 -->
			<view class="lb-user">
				<view class="user-top">
					<view class="avatar">
						<u-avatar :src="getImgUrl(data.avatar)" size="120rpx"></u-avatar>
					</view>
					<view class="info">
						<view class="name">
							{{data.name || ''}}
						</view>
						<view class="tel">
							<image src="/static/fen-xiao/icon/tel.png" mode=""></image>
							<text>{{data.mobile || ''}}</text>
						</view>
					</view>
				</view>

				<view class="user-tj">
					<view class="tj-item" v-for="(item,index) in tjData" :key="index">
						<view class="numb" :class="index < 2?'price':''">
							{{item.val || 0}}
						</view>
						<view class="label">
							{{item.key}}
						</view>
					</view>
				</view>
			</view>
			<!-- 服务 -->
			<view class="lb-serve">
				<view class="serve-item" v-for="(item,index) in serveData" :key="index" @click="goTo(item.url)">
					<view class="icon">
						<image :src="item.icon" mode=""></image>
					</view>
					<view class="lable">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		homeApiData
	} from "@/api/apis/retail.js"
	import {
		setImgUrl,
		fmtFormat
	} from "@/utils/comm.js"
	export default {
		data() {
			return {
				src: '',
				data: '',
				tjData: [{
						val: 0,
						key: '今日提现'
					},
					{
						val: 0,
						key: '总提现'
					},
					{
						val: 0,
						key: '订单数'
					}
				],
				serveData: [{
						name: '渠道商品',
						icon: '/static/fen-xiao/icon/01.png',
						url: '/pages/channel/channel-goods/channel-goods'
					},
					{
						name: '商品设计',
						icon: '/static/my/24.png',
						url: '/pages/channel/goods-design/goods-design'
					},
					{
						name: '我的商品',
						icon: '/static/fen-xiao/icon/02.png',
						url: '/pages/channel/my-goods/my-goods'
					},
					{
						name: '赠送记录',
						icon: '/static/fen-xiao/icon/04.png',
						url: '/pages/channel/give-list/give-list'
					},
					{
						name: '提成明细',
						icon: '/static/fen-xiao/icon/00.png',
						url: '/pages/channel/withdrawal-details/withdrawal-details'
					},
					{
						name: '提现记录',
						icon: '/static/fen-xiao/icon/06.png',
						url: '/pages/channel/withdrawal-list/withdrawal-list'
					},
					{
						name: '公告消息',
						icon: '/static/my/50.png',
						url: '/pages/channel/notice/notice'
					}
				],
			}
		},
		methods: {
			getImgUrl(img) {
				return setImgUrl(img);
			},
			//跳转
			goTo(url) {
				if (url) {
					uni.navigateTo({
						url: url
					})
				}
			},
			getData() {
				uni.showLoading({
					title: '请求中',
					mask: true
				});
				homeApiData().then(res => {
					uni.hideLoading();
					if (res.code == 1) {
						this.data = res.data;
						this.tjData[0].val = res.data.today_cash;
						this.tjData[1].val = res.data.cash
						// this.tjData[2].val = res.data.num
						this.tjData[2].val = res.data.order_num
					}
				})
			}
		},
		onShow() {
			this.getData();
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
	}

	.foot-tip {
		padding: 15rpx;
		border: 1px dashed #666;
		margin: 30rpx 0;
		border-radius: 10rpx;
		font-size: 28rpx;
		color: #666;
	}

	.lb-user {
		background: linear-gradient(135deg, #F56542 0%, #F5996A 100%);
		border-radius: 16rpx;
		padding: 28rpx 30rpx;

		.user-top {
			display: flex;

			.avatar {
				width: 120rpx;
				height: 120rpx;
				background: rgba(255, 255, 255, 0.39);
				border: 4rpx solid #F5F5F5;
				border-radius: 50%;
			}

			.info {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				padding-left: 24rpx;

				.name {
					font-size: $main-font-32;
					font-weight: bold;
					color: $main-font-color-white;
				}

				.tel {
					display: flex;
					align-items: center;
					padding-bottom: 18rpx;

					image {
						width: 32rpx;
						height: 32rpx;
						margin-right: 6rpx;
					}

					text {
						font-size: $main-font-24;
						color: $main-font-color-white;
					}
				}
			}
		}

		.user-tj {
			display: grid;
			grid-template-columns: repeat(3, 1fr);
			grid-gap: 30rpx 0;
			padding: 32rpx 0 0;

			.tj-item {
				display: flex;
				flex-direction: column;
				align-items: center;

				.numb {
					font-size: $main-font-32;
					font-weight: 400;
					color: $main-font-color-white;


				}

				.price {
					&::before {
						content: "¥ ";
						font-size: $main-font-20;
					}
				}

				.label {
					font-size: $main-font-24;
					font-weight: 400;
					color: $main-font-color-white;
				}
			}
		}

	}

	// 服务
	.lb-serve {
		display: grid;
		grid-template-columns: repeat(4, 1fr);
		grid-gap: 30rpx 0;
		padding: 32rpx 0 0;

		.serve-item {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.icon {
				width: 60rpx;
				height: 60rpx;
			}

			.lable {
				padding-top: 12rpx;
				font-size: $main-font-24;
				font-weight: 400;
				color: $main-font-color;
			}
		}

	}
</style>